package com.topsun.posclient.sales.view;

import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

public class PartSaleView extends ViewPart {

	public static final String ID = "posclient.PartSaleView";
	
	private Text storename; // 店铺名称
	private Text number;    // 单据号
	private Text balloter;  // 收银员
	private Text ballnumber; // 收银单号
	private Text balance; // 可用余额
	private Text remark;  // 备注
	
	private TableViewer goodsView;
	
	public void createPartControl(Composite container) {
		
		// container.setBackgroundImage(getDefaultImage());
		container.setSize(500, 500);
		GridLayout layout = new GridLayout(6,false);
		container.setLayout(layout);
		
		new Label(container, SWT.NONE).setText("店铺:");
		storename = new Text(container, SWT.SINGLE | SWT.BORDER);
		GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		storename.setLayoutData(gridData);
		
		new Label(container, SWT.NONE).setText("单据号:");
		number = new Text(container, SWT.SINGLE | SWT.BORDER);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		number.setLayoutData(gridData);
		
		
		new Label(container, SWT.NONE).setText("收银员:");
		balloter = new Text(container, SWT.SINGLE | SWT.BORDER);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		balloter.setLayoutData(gridData);
		
		new Label(container, SWT.NONE).setText("收银单号:");
		ballnumber = new Text(container, SWT.SINGLE | SWT.BORDER);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		ballnumber.setLayoutData(gridData);
		
		
		new Label(container, SWT.NONE).setText("可用余额:");
		balance = new Text(container, SWT.SINGLE | SWT.BORDER);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		balance.setLayoutData(gridData);
		
		
		new Label(container, SWT.NONE).setText("备注:");
		remark = new Text(container, SWT.SINGLE | SWT.BORDER);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 2;
		remark.setLayoutData(gridData);
		
		goodsView = new TableViewer(container,SWT.BORDER|SWT.MULTI|SWT.FULL_SELECTION);
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		gridData.horizontalSpan = 6;
		container.setLayoutData(gridData);
		Table table = goodsView.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		TableLayout tLayout = new TableLayout();
		table.setLayout(tLayout);
		tLayout.addColumnData(new ColumnWeightData(40));
		new TableColumn(table,SWT.NONE).setText("商品搜索");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("款号");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("数量");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("价格清单");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("零售价");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("折扣库");
		tLayout.addColumnData(new ColumnWeightData(40));
		new TableColumn(table,SWT.NONE).setText("折扣金额");
		tLayout.addColumnData(new ColumnWeightData(40));
		new TableColumn(table,SWT.NONE).setText("单价");
		tLayout.addColumnData(new ColumnWeightData(40));
		new TableColumn(table,SWT.NONE).setText("金额");
		tLayout.addColumnData(new ColumnWeightData(60));
		new TableColumn(table,SWT.NONE).setText("单品积分");
	}

	public void setFocus() {
		
	}
}
